﻿using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Tradukisto.DataAccess;
using Tradukisto.Model;

namespace Tradukisto.Controllers.API
{
    public class LookupController : ApiController
    {
        #region Controllers

        public HttpResponseMessage GetAllControllers(string filter)
        {
            return Request.CreateResponse(HttpStatusCode.OK, GetAllControllresImpl(filter));
        }

        private List<ControllerItem> GetAllControllresImpl(string filter)
        {
            return Manager.GetControllers(filter);
        }
        #endregion

        #region Actions

        public HttpResponseMessage GetAllActions(string filter, string controllerName)
        {
            return Request.CreateResponse(HttpStatusCode.OK, GetAllActionsImpl(filter, controllerName));
        }

        private List<ActionItem> GetAllActionsImpl(string filter, string controllerName)
        {
            return Manager.GetActions(filter, controllerName );
        }
        #endregion

        #region Cultures

        public HttpResponseMessage GetAllCultures(string filter)
        {
            return Request.CreateResponse(HttpStatusCode.OK, GetAllCulturesImpl(filter));
        }

        private List<Culture> GetAllCulturesImpl(string filter)
        {
            return Manager.GetCultures(filter);
        }
        #endregion

        #region Names

        public HttpResponseMessage GetAllNames(string filter)
        {
            return Request.CreateResponse(HttpStatusCode.OK, GetAllNamesImpl(filter));
        }

        private List<string> GetAllNamesImpl(string filter)
        {
            return Manager.GetNames(filter);
        }
        #endregion
    }
}
